package com.aifast.gen.business.dao;

import com.aifast.gen.business.entity.GenTable;
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 * 代码生成业务表 Mapper 接口
 * </p>
 *
 * @author fujian
 * @since 2022-05-23
 */
@Mapper
public interface GenTableDao extends BaseMapper<GenTable> {

    @InterceptorIgnore(tenantLine = "true")
    Page<GenTable> dbList(String searchValue, Page page);

    @InterceptorIgnore(tenantLine = "true")
    @Select("select table_name, table_comment, create_time, update_time from information_schema.tables\n" +
            "\t\twhere table_name NOT LIKE 'qrtz_%' and table_name NOT LIKE 'gen_%' and table_schema = (select database()) and table_name = #{table}")
    GenTable get(String table);

    /**
     * 查询表ID业务信息
     *
     * @param id 业务ID
     * @return 业务信息
     */
    @InterceptorIgnore(tenantLine = "true")
    GenTable selectGenTableById(Long id);

    /**
     * 查询表名称业务信息
     *
     * @param tableName 表名称
     * @return 业务信息
     */
    @InterceptorIgnore(tenantLine = "true")
    public GenTable selectGenTableByName(String tableName);
}
